package com.imwmw.signman;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

public class SignActivity extends AbsSignActivity {

    @Override
    ViewGroup getSignView() {
        FrameLayout rootView = (FrameLayout) LayoutInflater.from(this).inflate(R.layout.layout_sign, null);
        return rootView;
    }

    @Override
    int getSignColor() {
        return 0xFF111111;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        findViewById(R.id.button_clear).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                clear();
            }
        });

        findViewById(R.id.button_confirm).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String signFilePath = Environment.getExternalStorageDirectory() + "/sign.png";
                boolean res = saveBitmap(signFilePath, Bitmap.CompressFormat.PNG, 100);
                if (res) {
                    Log.i("SignMan", "save bitmap success.");
                } else {
                    Log.i("SignMan", "save bitmap fail!");
                }
            }
        });
    }
}
